<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>合同管理页面</title>
	<link rel="stylesheet" type="text/css" href="../Styles/admin-all.css" />
    <link rel="stylesheet" type="text/css" href="../Styles/base.css" />
    <link rel="stylesheet" type="text/css" href="../Styles/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
	<link rel="stylesheet" type="text/css" href="../Styles/bootstrap-3.3.7-dist/css/bootstrap-theme.min.css" />
    <script type="text/javascript" src="../Scripts/jquery.min.js"></script>
    <script type="text/javascript" src="../Styles/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../Styles\laypage\laypage.js"></script>
    <script language="javascript" type="text/javascript" src="../Styles/My97DatePicker/WdatePicker.js"></script>
    <link href="../Styles/My97DatePicker/skin/WdatePicker.css" rel="stylesheet" type="text/css">
    <style type="text/css">
    	#contr{
    		width: 80%;
    		height: 60%;
    		margin: auto;
            margin-top: 30px;
    	}
    	.button-operation{
    		margin-bottom: 10px;
    	}
    </style>
</head>
<body>
<div id="contr">
	<h2 style="margin-bottom: 20px;background: oldlace;height: 50px;padding-top: 8px">合同管理</h2>
    <div id="tr">
        <form action="" class="form-search">
        	
            <div class="search_area">
    			<form action="">
					<input type="hidden" name="ac" value="humancontract">
					<input type="hidden" name="do" value="list">
					<input type="hidden" name="fileurl" value="human">
        			<div class="form-search form-search-top" style="text-align:left;padding-left:10px;padding-bottom: 10px;">      			          
	        			<span class="adv-select-label">单位员工：</span>
       					<input type="text" name="user" id="user" style="width:70px;height:20px;background-color:#F5F5F5;color:#006600;" value="" readonly="">
       					<input type="hidden" name="userid" id="userid" value=""> 
       					<a href="javascript:void(0)" id="adduname">+选择人员</a>
   						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<span class="adv-select-label">合同类型：</span>
       					<select name="type" style="width:90px;" id="type">
							<option value="" selected="selected">请选择类型</option>
							<option value="劳务合同">劳务合同</option>
							<option value="保密合同">保密合同</option>
							<option value="其它">其它</option>						
						</select>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<span class="adv-select-label">合同状态：</span>
       					<select name="ckey" style="width:90px;" id="status">
							<option value="" selected="selected">请选择状态</option>
							<option value="试用期">试用期</option>
							<option value="己转证">己转证</option>
							<option value="己解除">己解除</option>			
						</select>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            			<button id="do_search" type="button" class="btn btn-primary">查 询</button>
           				&nbsp;&nbsp;&nbsp;
           				<button type="button" class="btn" id="showmore">切换更多查询</button>
        			</div>
        			
       				<div class="form-search form-search-bottom query-fom-search" id="dynamicDiv" style="margin-top: 10px; text-align: left; padding-left: 10px;padding-bottom: 10px;display:none;"> 
	   					<span class="adv-select-label">签订日期：</span>
       					<input id="date1" class="BigInput" type="text" name="testdate" style="width:168px;" size="20" onclick="WdatePicker({skin:'ext',dateFmt:'yyyy-MM-dd',minDate:'2008-03-08',maxDate:'2100-03-10'})">
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<span class="adv-select-label">试用生效日期：</span>
       					<input id="date2" class="BigInput" type="text" name="testdate" style="width:168px;" size="20" onclick="WdatePicker({skin:'ext',dateFmt:'yyyy-MM-dd',minDate:'2008-03-08',maxDate:'2100-03-10'})">
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<span class="adv-select-label">试用到期日期：</span>
       					<input id="date3" class="BigInput" type="text" name="testdate" style="width:168px;" size="20" onclick="WdatePicker({skin:'ext',dateFmt:'yyyy-MM-dd',minDate:'2008-03-08',maxDate:'2100-03-10'})">
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<span class="adv-select-label">合同到期日期：</span>
       					<input id="date4" class="BigInput" type="text" name="testdate" style="width:168px;" size="20" onclick="WdatePicker({skin:'ext',dateFmt:'yyyy-MM-dd',minDate:'2008-03-08',maxDate:'2100-03-10'})">
       				</div>   
    			</form>
			</div>
			
            <div class="button-operation">
				<button type="button" class="btn btn-success" onclick="javascript:window.location='addcon.jsp'">发布信息</button>				
				<button type="button" onclick="updateform(1);" class="btn btn-danger">清理数据</button>
				<button type="button" id="query_export" class="btn btn-info">导出查询列表</button>				
			</div>

            <table class="table table-bordered table-hover" width="100%">
            	<thead>
            		<tr class="info"><th colspan="10">出差申请列表</th></tr>
	            	<tr class="editThead info" align="center">
	      				<td width="40" style="width: 40px;"><input type="checkbox" value="1" id="chkall" name="chkall" onclick="check_all()"></td>
	      				<td width="100" style="width: 100px;">合同编号</td>
						<td style="width: 267px;">单位员工</td>
						<td width="120" style="width: 120px;">合同类型</td>
						<td width="100" style="width: 100px;">合同状态</td>
						<td width="120" style="width: 120px;">合同签订日期</td>
						<td width="120" style="width: 120px;">合同到期日期</td>
						<td width="100" style="width: 100px;">签约次数</td>
						<td width="100" style="width: 100px;">发布人</td>
						<td width="120" style="width: 120px;">操作</td>
	   				</tr>
   				</thead>
   				<tbody id="tb">
   					
   				</tbody>
   			</table>
            <div id="page" style="float: right;"></div>
        </form>
    </div>
    
    <!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						&times;
					</button>
					<h4 class="modal-title" id="myModalLabel">
						显示员工姓名表单
					</h4>
				</div>
				<div class="modal-body">
					<form action="">
						<input type="hidden" value="" class="tr_id" name="hid"/>
						<table class="table table-hover">
							<thead>
					        	<tr class="info"><th>显示部门名称</th><th>显示员工名称</th></tr>
					        </thead>
					        <tbody id="tb">
					        	<tr><td id="tb1" class='error'></td><td id="tb2"></td></tr>			
					        </tbody>
					        							
						</table>
					</form>
				</div>
				<div class="modal-footer">  
	                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>  
	                <button type="button" class="btn btn-primary" id="btn1">确定</button>  
	            </div> 
			</div><!-- /.modal-content -->
		</div><!-- /.modal -->
	</div>
    
    <!-- 查看人事合同信息 -->
    <div class="modal fade" id="selectCon" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						&times;
					</button>
					<span style="font-size: 20px"><img alt="" src="../img/select.png"> <span id="con_emp"></span>   人事合同信息浏览</span>
				</div>
				<div class="modal-body">
					<form name="save" method="post" action="">
						<table class="table" border="0" width="90%" align="center" style="border-bottom:#4686c6 solid 0px;">
						    <tbody>
						      <tr>
						        <td nowrap="" class="warning" width="20%">单位员工</td>
						        <td class="d1" width="30%"></td>
						        <td nowrap="" class="warning" width="20%">合同编号</td>
						        <td class="d2" width="30%"></td>
						      </tr>
							 
							  <tr>
						        <td nowrap="" class="info"> 合同类型：</td>
						        <td class="d3"></td>
						        <td nowrap="" class="info"> 合同状态：</td>
						        <td class="d4"></td>
						      </tr>
						      
						      <tr>
						      	<td nowrap="" class="success"> 合同签订日期：</td>
						        <td class="d5"></td>
						        <td nowrap="" class="success"> 合同到期日期：</td>
						        <td class="d6"></td>
						      </tr>
							  						 
							  <tr>
						        <td nowrap="" class="warning"> 试用生效日期：</td>
						        <td class="d7"></td>
						        <td nowrap="" class="warning"> 试用到期日期：</td>
						        <td class="d8"></td>
						      </tr>
						      
							  <tr>
						        <td nowrap="" class="info"> 试用天数：</td>
						        <td class="d9"></td>
						        <td nowrap="" class="info"> 签约次数：</td>
						        <td class="d10"></td>
						      </tr>				 
						   						      
							  <tr>
						        <td nowrap="" class="success" > 附件文档：</td>
						        <td class="d11" colspan="3"><input type="hidden" class="d13" value=""/></td>
						      </tr>
						      
							  <tr>
							  	<td nowrap="" class="warning" > 备注：</td>
						        <td colspan="3" nowrap="" class="d12"></td>
						      </tr>
							</tbody>
						</table>
					</form>
					
				</div>
				<div class="modal-footer">  
	                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>  
	                <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>  
	            </div> 
			</div><!-- /.modal-content -->
		</div><!-- /.modal -->
	</div>
</div>

<script type="text/javascript">

/*全选/反选触发函数*/
function check_all(){
     var del = document.getElementById("chkall").checked;
     var arrState = document.getElementsByName("chk1");
    
     for(var i = 0;i<arrState.length;i++){
            arrState[i].checked = del;
            
     }
 };

var con_emp=$("#user").val();
var con_type=$("#type").val();
var con_status=$("#status").val();
var con_signdate=$("#date1").val();
var con_trydate=$("#date2").val();
var con_tryend=$("#date3").val();
var con_end=$("#date4").val();

var currentPage=1;

$(function(){
	
	//点击到处查询列表
	$(document).on('click','#query_export',function(){
		
		var param="emp="+con_emp+"&type="+con_type+"&status="+con_status+"&date1="+con_signdate+"&date2="+con_trydate+"&date3="+con_tryend+"&date4="+con_end;
		window.open("<c:url value='../showCon/export?"+param+"'/>");
	});
	
	getCon();
	function getCon(){
		$.ajax({
			url:"../showCon/showContract",
			type:"post",
			data:{"currentPage":currentPage,"emp":con_emp,"type":con_type,"status":con_status,"date1":con_signdate,"date2":con_trydate,"date3":con_tryend,"date4":con_end},
			dataType:"json",
			
			success:function(result){
				console.log(result);
    			
    			 $("#tb").html("");
    			 $.each(result.contrUsers,function(inx,ele){
    				 $("#tb").append(
    					"<tr class='editThead' align='center'>"+
    		      			"<td width='40' style='width: 40px;'><input type='checkbox' name='chk1'></td>"+
    		      			"<td width='100' style='width: 100px;'><a href='javascript:void(0)' id='con_num'>"+ele.con_num+"</a></td>"+
    						"<td style='width: 267px;'>"+ele.con_emp+"</td>"+
    						"<td width='120' style='width: 120px;'>"+ele.con_type+"</td>"+
    						"<td width='100' style='width: 100px;'>"+ele.con_status+"</td>"+
    						"<td width='120' style='width: 120px;'>"+ele.con_signdate+"</td>"+
    						"<td width='120' style='width: 120px;'>"+ele.con_end+"</td>"+
    						"<td width='100' style='width: 100px;'>"+ele.con_signnum+"</td>"+
    						"<td width='100' style='width: 100px;'>"+ele.uname+"</td>"+
    						"<td width='120' style='width: 120px;'><a href='../showCon/findCon1?con_id="+ele.con_id+"'>编辑</a></td>"+
    		   			"</tr>"	
   					 )
    				
   					laypage({
     					  cont: $("#page"),  //容器
     					  pages: result.pages, //总页数
     					  curr:currentPage,     //当前页, 
     					  skin: 'molv', //皮肤
     					  skip:true, //支持跳页的功能
     					  last:'尾页',
     					  groups:3,  //多少页进行分组
     					  jump: function(obj, first){ //触发分页后的回调
     						currentPage = obj.curr;
     					    if(!first){   //一定要加此判断，否则初始时会无限刷新
     					      getCon();  //获取当前页
     					    }
     					  }
     					});
    			 })
			}
		})
	};
	
	//点击查询按钮
	$("#do_search").click(function(){
		con_emp=$("#user").val();
		console.log(con_emp);
		con_type=$("#type").val();
		console.log(con_type);
		con_status=$("#status").val();
		console.log(con_status);
		con_signdate=$("#date1").val();
		con_trydate=$("#date2").val();
		con_tryend=$("#date3").val();
		con_end=$("#date4").val();
		getCon();
		$("#dynamicDiv").hide();
   	});
	
	//点击事件，查看信息
	$(document).on('click','#con_num',function(){
		var con_num=$(this).html();
		console.log(con_num);
		$.ajax({
			url:"../showCon/findCon",
			type:"post",
			data:{"con_num":con_num},
			dataType:"json",
			
			success:function(result){
				console.log(result);
				$("#con_emp").html(result.contract.con_emp);
				$(".d1").html(result.contract.con_emp);
				$(".d2").html(result.contract.con_num);
				$(".d3").html(result.contract.con_type);
				$(".d4").html(result.contract.con_status);
				$(".d5").html(result.contract.con_signdate);
				$(".d6").html(result.contract.con_end);
				$(".d7").html(result.contract.con_trydate);
				$(".d8").html(result.contract.con_tryend);
				$(".d9").html(result.contract.con_tryday);
				$(".d10").html(result.contract.con_signnum);
				$(".d11").html("<a href='../showCon/down?fileName="+result.contract.con_enclo+"' id='down'>下载附件</a>");
				$(".d13").html(result.contract.con_enclo);
				$(".d12").html(result.contract.con_remaks);
				$("#selectCon").modal("show");
			}
		})
		
	});
	
	//点击显示更多查询信息
	$(document).on('click','#showmore',function(){
		$("#dynamicDiv").show();
	});
	
	//点击事件，显示部门名称
	$(document).on('click','#adduname',function(){
		$.ajax({
			url:"../showCon/findSec",
			type:"post",
			dataType:"json",
			
			success:function(result){
				console.log(result.sections);
				$("#myModal").modal("show");
				$("#tb1").html("");
   			 	$.each(result.sections,function(inx,ele){
   			 		$("#tb1").append(
							"<ul><li><a href='javascript:void(0)' id='uname'>"+ele.deptname+"</a><input type='hidden' value='"+ele.seorid+"' id='hid'/></li></ul>"
   			 				/* "<tr><td class='warning' id='deptname'><a href='javascript:void(0)' id='uname'>"+ele.deptname+"</a></td><td></td></tr>" */
					 )
   			 	})
			}
		})
		
	});
	
	//点击事件，显示部门成员信息
	$(document).on('click','#uname',function(){
		var seorid=$(this).siblings("#hid").val();
		console.log(seorid);
		$.ajax({
			url:"../showCon/findUser",
			type:"post",
			data:{"seorid":seorid},
			dataType:"json",
			
			success:function(result){
				console.log(result.users);
				
				$("#tb2").html("");
   			 	$.each(result.users,function(inx,ele){
   			 		$("#tb2").append(
							"<ul><li><input type='radio' name='m' value='"+ele.uname+"'/><a href='javascript:void(0)' id='uname'>"+ele.uname+"</a></li></ul>"
					 )
   			 	})
			}
		})
		
	});
	
	//弹出层的确定按钮的点击时间
	$(document).on('click','#btn1',function(){
		var uname=$("input[type='radio']:checked").val();
		console.log(uname);
		$("#myModal").modal("hide");
		$("#user").val(uname);		
	});
})

</script>
</body>
</html>